local skel = fk.CreateSkill{
  name = "tea__bingxin",
}
--local U = require "packages/utility/utility"
Fk:loadTranslationTable{
  ["tea__bingxin"] = "冰心",
  [":tea__bingxin"] = "当你造成或受到伤害时，你可以依次弃置受到伤害的角色两张牌，防止此伤害，然后你可以令一名其他角色回复1点体力。",
  ["#tea__bingxin-discard"] = "冰心：你需要依次弃置 %src 两张牌（现在是第 %arg 张）",
  ["#tea__bingxin-choose"] = "冰心：你可以选择一名其他角色，令其回复1点体力",
}
---@type TrigSkelSpec<DamageTrigFunc>
local bingxin = {
  anim_type = "defensive",
  can_trigger = function (self, event, target, player, data)
    return player == target and player:hasSkill(skel.name) and data.to and not data.to:isNude()
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = data.to
    room:doIndicate(player, { to })
    data:preventDamage()
    for i = 1, 2 do
      if not player.dead and not to.dead and not to:isNude() then
        if player == to then
          local cid = room:askToDiscard(player, {
            min_num = 1,
            max_num = 1,
            cancelable = false,
            skill_name = skel.name,
            prompt = "#tea__bingxin-discard:" .. to.id .. "::" .. i,
            include_equip = true
          })
        else
          local cid = room:askToChooseCard(player, {
            target = to,
            skill_name = skel.name,
            flag = "he",
            prompt = "#tea__bingxin-discard:" .. to.id .. "::" .. i,
          })
          if cid then
            room:throwCard(cid, skel.name, to, player)
          end
        end
      end
    end
    if not player.dead then
      local targets = table.filter(room:getOtherPlayers(player), function(p)
        return p:isWounded()
      end)
      if #targets > 0 then
        local to2 = room:askToChoosePlayers(player, {
          min_num = 1,
          max_num = 1,
          targets = targets,
          skill_name = skel.name,
          prompt = "#tea__bingxin-choose"
        })[1]
        if to2 then
          room:recover{
            who = to2,
            num = 1,
            skillName = skel.name
          }
        end
      end
    end
  end
}
skel:addEffect(fk.DamageCaused, bingxin)
skel:addEffect(fk.DamageInflicted, bingxin)
-- Fk.generals["mouxusheng"]:addSkill(skel.name)
return skel